package com.hui.web.servlet.classServlet;

import com.hui.bean.ClassBean;
import com.hui.service.IClassService;
import com.hui.service.impl.ClassServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "ClassIndexServlet",urlPatterns = "/class/index")
public class ClassIndexServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String currentPage = request.getParameter("currentPage");
        IClassService classService=new ClassServiceImpl();
        List<ClassBean> allClasses = classService.getAllClasses();
//        System.out.println(allClasses);
        request.setAttribute("classList",allClasses);
        request.getRequestDispatcher("/page/class/index.jsp").forward(request, response);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
